<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
// 如下参数需要被赋值才能被正常使用，以下是示例
/*  
	<c:set var="currentPage" value="${blogPage.pageNumber}" />
	<c:set var="totalPage" value="${blogPage.totalPage}" />
	<c:set var="actionUrl" value="/blog/" />
	<c:set var="urlParas" value="" />
*/
%>

<c:if test="${urlParas == null}">
	<c:set var="urlParas" value="" />
</c:if>
<c:if test="${(totalPage > 0) && (currentPage <= totalPage)}">
	<c:set var="startPage" value="${currentPage - 4}" />
	<c:if test="${startPage < 1}" >
		<c:set var="startPage" value="1" />
	</c:if>
	<c:set var="endPage" value="${currentPage + 4}" />
	<c:if test="${endPage > totalPage}" >
		<c:set var="endPage" value="totalPage" />
	</c:if>
<c:if test="${in_table == 0 }">
<nav class="pull-right">
	<ul class="pagination">
</c:if>
		<c:if test="${currentPage <= 8}">
			<c:set var="startPage" value="1" />
		</c:if>
		
		<c:if test="${(totalPage - currentPage) < 8}">
			<c:set var="endPage" value="${totalPage}" />
		</c:if>
		
		<c:choose>
			<c:when test="${currentPage == 1}">
				<li class="disabled">
			      <a href="javascript:void(0)" aria-label="Previous">&laquo;</a>
			    </li>
			</c:when>
			<c:otherwise>
				<li>
                  <a href="${actionUrl}/?page=${currentPage - 1}${urlParas}" aria-label="Previous">&laquo;</a>
                </li>
			</c:otherwise>
		</c:choose>
		
		<c:if test="${currentPage > 8}">
			<li><a href="${actionUrl}/${1}${urlParas}">${1}</a></li>
			<li><a href="${actionUrl}/${2}${urlParas}">${2}</a></li>
			<li class="disabled"><a href="javascript:void(0)">...</a></li>
		</c:if>
		
		<c:forEach begin="${startPage}" end="${endPage}" var="i">
			<c:choose>
				<c:when test="${currentPage == i}">
					<li class="active"><a href="javascript:void(0)">${i}</a></li>
				</c:when>
				<c:otherwise>
					<li><a href="${actionUrl}/?page=${i}${urlParas}">${i}</a></li>
				</c:otherwise>
			</c:choose>
		</c:forEach>
		
		<c:if test="${(totalPage - currentPage) >= 8}">
			<li class="disabled"><a href="javascript:void(0)">...</a></li>
			<li><a href="${actionUrl}/?page=${totalPage - 1}${urlParas}">${totalPage - 1}</a></li>
			<li><a href="${actionUrl}/?page=${totalPage}${urlParas}">${totalPage}</a></li>
		</c:if>
		
		<c:choose>
			<c:when test="${currentPage == totalPage}">
				<li class="disabled">
                  <a href="javascript:void(0)" aria-label="Next">&raquo;
                  </a>
                </li>
			</c:when>
			<c:otherwise>
				<li>
                  <a href="${actionUrl}/?page=${currentPage + 1}${urlParas}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                  </a>
                </li>
			</c:otherwise>
		</c:choose>
<c:if test="${in_table == 0 }">
	</ul>
</nav>
</c:if>
</c:if>